package leetCodeEveryday.Test2389和有限的最长子序列;

import java.util.Arrays;

public class Solution {
    public int[] answerQueries(int[] nums, int[] queries) {
        Arrays.sort(nums);
        int[] result = new int[queries.length];

        for (int i = 0; i < queries.length; i++) {
            int query = queries[i];
            int count = 0;
            int sum = 0;
            for (count = 0; count < nums.length; count++) {
                sum += nums[count];
                if (sum > query) {
                    break;
                }
            }
            result[i] = count;
        }
        return result;
    }
}
